package com.every.utils;

import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @description: 字符串工具
 * @author: yh
 * @date: 2022/11/20
 */
public class StrUtil {

    /**
     * 随机取字符串
     *
     * @param list 字符串集合
     * @author: yh
     * @date: 2022/11/11
     */
    public static String getRandomStr(List<String> list) {
        if (CollectionUtils.isEmpty(list)) {
            return "";
        }
        int index = (int) (Math.random() * list.size());
        return list.get(index);
    }
}
